export function tab(arr, arrIndex) {
  let list = [];
  switch (arrIndex) {
    case 1:
      list.push({
        toArr: getToArr(arr, arrIndex),
        fromArr: getfromArr(arr, arrIndex),
      });
      return list;
    case 7:
      list.push({
        toArr: getToArr(arr, arrIndex),
        fromArr: getfromArr(arr, arrIndex),
      });
      return list;
    case 8:
      list.push({
        toArr: getToArr(arr, arrIndex),
        fromArr: getfromArr(arr, arrIndex),
      });
      return list;
    default:
      break;
  }
}

function getToArr(arr, arrIndex) {
  let ss = arr.slice(0, arrIndex);
  console.log(ss);
  let fromArr = [];
  for (let i = 0; i < ss.length; i++) {
    let fromObj = ss[i].toArr;
    for (let j = 0; j < fromObj.length; j++) {
      let fromArrObj = fromArr[j];
      if (fromArrObj === "" || fromArrObj === undefined) {
        fromArrObj = [];
      }
      fromArrObj.push(fromObj[j]);
      fromArr[j] = fromArrObj;
    }
  }
  let fromArr1 = [];
  fromArr.forEach((item) => {
    let num = 0;
    item.forEach((v) => {
      num = v + num;
    });
    fromArr1.push(num);
  });
  return fromArr1;
}
function getfromArr(arr, arrIndex) {
  let ss = arr.slice(0, arrIndex);
  let fromArr = [];
  for (let i = 0; i < ss.length; i++) {
    let fromObj = ss[i].fromArr;
    for (let j = 0; j < fromObj.length; j++) {
      let fromArrObj = fromArr[j];
      if (fromArrObj === "" || fromArrObj === undefined) {
        fromArrObj = [];
      }
      fromArrObj.push(fromObj[j]);
      fromArr[j] = fromArrObj;
    }
  }
  let fromArr2 = [];
  fromArr.forEach((item) => {
    let num = 0;
    item.forEach((v) => {
      num = v + num;
    });
    fromArr2.push(num);
  });
  return fromArr2;
}
